import { isDelUser } from '@/static/js/user'
export default {
	data() {
		return {
			userInfo: {},
			menuList: [{
				name: '修改登录密码',
				url: '/pages/my/settings/editPassword?type=2',
				isShow: true
			}, {
				name: '设置登录密码',
				url: '/pages/my/settings/editPassword?type==1',
				isShow: true
			}, {
				name: '账号注销',
				url: '/pages/my/settings/SignOUT',
				isShow: true,
				handler: 'isDelUser'
			},],
			platform: '',
			signOutPopup: false, //注销弹窗提示
		};
	},
	onLoad(e) {
		this.userInfo = uni.getStorageSync('userInfo') || {}
		// 是否有密码
		if (this.userInfo.password != '') {
			this.menuList[1].isShow = false;
		} else {
			this.menuList[0].isShow = false;
		}

	},
	methods: {
		onClick(item) {
			if (item.handler) {
				this[item.handler]();
			} else if (item.url) {
				uni.navigateTo({
					url: item.url
				})
			}
		},
		isDelUser() {
			isDelUser().then(res => {
				if (res.code == 0) { //0是未注销  1是已注销
					uni.navigateTo({
						url: '/pages/my/settings/SignOUT'
					})
				} else {
					this.signOutPopup = true
					setTimeout(() => {
						this.signOutPopup = false
					}, 3000)
				}
			})
		},
	},
}